<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>城市选择</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<jsp:include page="/page/head.jsp"></jsp:include>
	<script type="text/javascript">
		$(function(){
	        var province = $('#province').combobox({
	            url:'${pageContext.request.contextPath}/city/dict/list.do?type=province',
	            editable:false,
	            valueField:'id',
	            textField:'name',
	            onSelect:function(record){
	                //刷新数据，重新读取省份下的城市，并清空当前输入的值
	                city.combobox({
	                    disabled:false,
	                    url:'${pageContext.request.contextPath}/city/dict/list.do?type=city&parentId='+record.id,
	                    valueField:'id',
	                    textField:'name'
	                }).combobox('clear');
	            }
	        });
	        
	        var city = $('#city').combobox({
	            disabled:true,
	            url:'${pageContext.request.contextPath}/city/dict/list.do?type=city',
	            valueField:'id',
	            textField:'name'
	        });
		});
		
		function save(){
			var ret = new Array();
			if($('#province').combobox('getText') == "" || $('#city').combobox('getText') == ""){
				alertBox("请选择省、市！");
				return;
			}
			if($('#city').combobox('getText') == "县" || $('#city').combobox('getText') == "区"){
				ret[0] = $('#province').combobox('getValue');
				ret[1] = $('#province').combobox('getText');
			}else{
				ret[0] = $('#city').combobox('getValue');
				ret[1] = $('#city').combobox('getText');
			}
			window.returnValue = ret;
			window.close();
		}
		
		function callback(){
			window.close();
		}
	</script>
  </head>
  
  <body>
  <div class="right">
	<form id="fm">
	<div class="ri_main">
		<table width="300" border="0" cellspacing="1" cellpadding="8" style="background:#d9d9d9;">
		  
		  <tr>
		    <td width="21%" align="right" bgcolor="#FFFFFF">省：</td>
		    <td width="79%" bgcolor="#FFFFFF">
		      <select id="province" style="width: 200px"></select>
		    </td>
		  </tr>
		  <tr>
		    <td align="right" bgcolor="#FFFFFF">市：</td>
		    <td bgcolor="#FFFFFF">
		      <select id="city" style="width: 200px"></select>
		    </td>
		  </tr>
		   
		   <tr>
		    <td align="center" bgcolor="#FFFFFF" colspan="2">
				<a href="javascript:void(0);" class="easyui-linkbutton" iconCls="icon-ok" onclick="save()">确定</a>
				<a href="javascript:void(0);" class="easyui-linkbutton" iconCls="icon-undo" onclick="callback()">取消</a>
			</td>
		   </tr>
		</table>
	</div>
	</form>
	</div>
  </body>
</html>